import vtkAnnotatedCubeActor from '@kitware/vtk.js/Rendering/Core/AnnotatedCubeActor';
import vtkAxesActor from '@kitware/vtk.js/Rendering/Core/AxesActor';
import macros from '@kitware/vtk.js/macros';
// import vtk from '@kitware/vtk.js/vtk';

import Constants from './Constants';

const { Representation } = Constants; // { POINT: 0, WIREFRAME: 1, ... }

// ----------------------------------------------------------------------------
// Global methods
// ----------------------------------------------------------------------------

// Add module-level functions or api that you want to expose statically via
// the next section...

function moduleScopedStaticMethod() {
  // do more stuff
}

// ----------------------------------------------------------------------------
// Static API
// ----------------------------------------------------------------------------

export const STATIC = {
  moduleScopedStaticMethod,
};

// ----------------------------------------------------------------------------
// vtkMyClass methods
// ----------------------------------------------------------------------------

function vtkAnnotatedCubeUgActor(publicAPI, model) {
  // Set our className
  model.classHierarchy.push('vtkAnnotatedCubeUgActor');

  // Capture "parentClass" api for internal use
  const superClass = Object.assign({}, publicAPI);

  // Public API methods
  publicAPI.exposedMethod = () => {
    // This is a publicly exposed method of this object
  };

  publicAPI.overriddenMethod = () => {
    superClass.overriddenMethod();
    // let's add my custom code here
    // ...
  };
}

// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------

const DEFAULT_VALUES = {
  myProp1: [0, 0, 0],
  // myProp2: null,     // Do not initialize internal objects here
  myProp3: true,
  myProp4: 6,
  myProp5: [1, 2, 3, 4],
  myProp6: Representation.WIREFRAME,
};

export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
  model.axisActor = vtkAxesActor.newInstance();
  model.annotatedCubeActor = vtkAnnotatedCubeActor.newInstance();

  publicAPI.getActors = () => [model.axisActor, model.annotatedCubeActor];
  publicAPI.getNestedProps = () => publicAPI.getActors();
  // Inheritance
  vtkAnnotatedCubeActor.extend(publicAPI, model, initialValues);
  // Internal objects initialization
  // if (model.myProp2) {
  //   model.myProp2 = vtk(model.myProp2);
  // } else {
  //   model.myProp2 = vtkAxesActor.newInstance();
  // }
  // Create get-only macros
  macros.get(publicAPI, model, ['myProp2', 'myProp4']);
  // Object specific methods
  vtkAnnotatedCubeUgActor(publicAPI, model);
}
export const newInstance = macros.newInstance(extend, 'vtkAnnotatedCubeUgActor');

export default Object.assign({ newInstance, extend }, STATIC, Constants);
